using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyElasticLogger.NETFramework.ES.Configuration
{
    /// <summary>
    /// Elasticsearch日志记录器配置
    /// </summary>
    public class LoggerConfiguration
    {
        /// <summary>
        /// 是否启用日志记录功能
        /// </summary>
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 索引前缀
        /// </summary>
        public string IndexPrefix { get; set; } = "app-log";

        /// <summary>
        /// 索引策略（固定索引或按日期滚动）
        /// </summary>
        public IndexStrategy IndexStrategy { get; set; } = IndexStrategy.DailyRolling;

        /// <summary>
        /// 固定索引名称（仅在IndexStrategy为Fixed时使用）
        /// </summary>
        public string FixedIndexName { get; set; }

        /// <summary>
        /// Elasticsearch集群配置
        /// </summary>
        public ClusterConfiguration Cluster { get; set; } = new ClusterConfiguration();

        /// <summary>
        /// 应用程序名称
        /// </summary>
        public string ApplicationName { get; set; } = "DefaultApp";

        /// <summary>
        /// 批量发送日志的大小
        /// </summary>
        public int BatchSize { get; set; } = 100;

        /// <summary>
        /// 发送超时时间（毫秒）
        /// </summary>
        public int TimeoutMs { get; set; } = 10000;
    }

    /// <summary>
    /// 索引策略枚举
    /// </summary>
    public enum IndexStrategy
    {
        /// <summary>
        /// 固定索引
        /// </summary>
        Fixed,

        /// <summary>
        /// 按日期滚动索引（默认）
        /// </summary>
        DailyRolling
    }

    /// <summary>
    /// Elasticsearch集群配置
    /// </summary>
    public class ClusterConfiguration
    {
        /// <summary>
        /// Elasticsearch节点地址列表
        /// </summary>
        public List<string> Nodes { get; set; } = new List<string>();

        /// <summary>
        /// 用户名（用于Basic认证）
        /// </summary>
        public string Username { get; set; }

        /// <summary>
        /// 密码（用于Basic认证）
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 是否启用SSL
        /// </summary>
        public bool UseSsl { get; set; } = false;

        /// <summary>
        /// 是否跳过SSL证书验证（仅在UseSsl为true时有效）
        /// </summary>
        public bool SkipSslVerification { get; set; } = false;

        /// <summary>
        /// 连接超时时间（毫秒）
        /// </summary>
        public int ConnectionTimeoutMs { get; set; } = 5000;

        /// <summary>
        /// 最大重试次数
        /// </summary>
        public int MaxRetries { get; set; } = 2;
    }
}